<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: blog_item_edit.php 11 2013-09-21 11:43:11Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 11 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 11:43:11 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

echo draw_form('item', FILENAME_BLOG, 'action=save_item', 'post')."\n".
draw_hidden_field('categories_id', $_GET['cat']);

if($_GET['action'] == 'new_item') {
	echo draw_hidden_field('action', 'insert');

} elseif($_GET['action'] == 'edit_item') {
	echo draw_hidden_field('action', 'update');
	echo draw_hidden_field('item', $_GET['item']);
}

$ask[] = array('id' => 0, 'text' => NO);
$ask[] = array('id' => 1, 'text' => YES);

$status[] = array('id' => 1, 'text' => TABLE_FOOTER_STATUS_1);
$status[] = array('id' => 2, 'text' => TABLE_FOOTER_STATUS_2);

?>
<table cellspacing="0" cellpadding="0">
	<tr>
		<td align="left" width="1">
			<a class="button" onclick="this.blur();" href="<?php echo href_link(FILENAME_BLOG,'action=showitems&subsite=seo&cat='.$_GET['cat']); ?>"><?php echo BUTTON_BACK; ?></a>
		</td>
		<td width="1">
			<?php echo '<button type="submit" class="button" onclick="this.blur();">'.BUTTON_SAVE.'</button>'; ?>
		</td>
	</tr>
</table><br />
<div id="tabs">
	<ul>
		<li><a href="#misc" onclick="return false;"><span>Grundeinstellungen</span></a></li>
		<?php for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { ?>
			<li><a href="#language_<?php echo $languages[$i]['id']; ?>" onclick="return false;">
					<span><img src="../lang/<?php echo $languages[$i]['directory'].'/'.$languages[$i]['image']; ?>" alt="" /> <?php echo $languages[$i]['name'] ?></span>
				</a>
			</li>
		<?php } ?>
	</ul>
	<div id="misc">
		<?php $items = $db->db_query("SELECT lenght, position, status, allow_comment FROM ".TABLE_BLOG_ITEMS." WHERE language_id = '".$_SESSION['languages_id']."' AND item_id = '".$_GET['item']."' "); ?>
		<table width="100%" cellspacing="0" cellpadding="0">
			<tr>
				<td class="main" width="1"><nobr><?php echo TABLE_HEADING_NEWCATEGORIE_POSITION;?></nobr></td>
				<td class="main"><?php echo draw_input_field('position', $items->fields['position'],'size="4"');?></td>
			</tr>
			<tr>
				<td class="main"><nobr><?php echo TABLE_HEADING_NEWITEM_LENGHT;?></nobr></td>
				<td class="main"><?php echo draw_input_field('lenght', $items->fields['lenght'],'size="4"');?></td>
			</tr>
			<tr>
				<td class="main"><?php echo ALLOW_COMMENT; ?></td>
				<td class="main"><?php echo draw_pull_down_menu('allow_comment', $ask, ($_GET['action']=='new_item'?1:$items->fields['allow_comment']), 'style="width:60px;"') ?></td>
			</tr>
			<tr>
				<td class="main">Status:</td>
				<td class="main"><?php echo draw_pull_down_menu('status', $status, ($_GET['action']=='new_item'?2:$items->fields['status']), 'style="width:100px;"') ?></td>
			</tr>
		</table>
	</div>
	<?php
		$languages = get_languages();
		for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
			if($_GET['action'] == 'edit_item') {
				$items = $db->db_query("SELECT
												title, name, meta_title, meta_keywords, meta_description, lenght, description, status
											FROM
												".TABLE_BLOG_ITEMS."
											WHERE
												language_id = '".$languages[$i]['id']."'
											AND
												item_id = '".$_GET['item']."' ");
			}
			?>
			<div id="language_<?php echo $languages[$i]['id'] ?>">
				<table width="100%" cellspacing="0" cellpadding="0">
					<tr>
						<td valign="top" colspan="2">
							<table width="100%" border="0" cellpadding="3" cellspacing="1" align="center">
								<tr>
									<td width="20%" class="main"><?php echo TABLE_HEADING_NEWITEM_NAME;?></td>
									<td class="main"><?php echo draw_input_field('name['.$languages[$i]['id'].']', $items->fields['name'],'style="width:60%"');?></td>
								</tr>
								<tr>
									<td width="20%" class="main"><?php echo TABLE_HEADING_NEWITEM_TITLE;?></td>
									<td class="main"><?php echo draw_input_field('title['.$languages[$i]['id'].']', $items->fields['title'],'style="width:60%"');?></td>
								</tr>
								<tr>
									<td class="main" colspan="2" height="20">&nbsp;</td>
								</tr>
								<tr>
									<td class="main"><?php echo TABLE_HEADING_META_TITLE;?></td>
									<td class="main"><?php echo draw_input_field('meta_title['.$languages[$i]['id'].']', $items->fields['meta_title'],'style="width:60%"');?></td>
								</tr>
								<tr>
									<td class="main"><?php echo TABLE_HEADING_META_DESCRIPTION;?></td>
									<td class="main"><?php echo draw_input_field('meta_description['.$languages[$i]['id'].']', $items->fields['meta_description'],'style="width:60%"');?></td>
								</tr>
								<tr>
									<td class="main"><?php echo TABLE_HEADING_META_KEYWORDS;?></td>
									<td class="main"><?php echo draw_input_field('meta_keywords['.$languages[$i]['id'].']', $items->fields['meta_keywords'],'style="width:60%"');?></td>
								</tr>
								<tr>
									<td class="main" colspan="2" height="20">&nbsp;</td>
								</tr>
								<tr>
									<td class="main" colspan="2"><?php echo TABLE_HEADING_DESC;?></td>
								</tr>
								<tr>
									<td class="main" colspan="2">
										<textarea name="description_<?php echo $languages[$i]['id'] ?>" id="textarea_<?php echo $languages[$i]['id'] ?>"><?php echo $items->fields['description']; ?></textarea>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</div>
		<?php } ?>
	</div>
</form>
<script type="text/javascript" src="includes/wysiwyg/wysiwyg.js.php?l=<?php echo $_SESSION['language_code'] ?>&id=<?php echo $_SESSION['languages_id'] ?>"></script>